export function msgInfoPrs(item, jsonAlarmMsg, editInfo, isDoorLock) {
	let alarmJson = {
		'DoorLockNotify': '门锁通知',
		'DoorLockCall': '来电提醒',
		'DoorLockAlarm': '异常消息',
		'VideoMotion': '移动侦测',
		'appEventHumanDetectAlarm': '人形检测',
	}
	let msgJson = {
		'FingerManger': '指纹',
		'PassWdManger': '密码',
		'CardManger': '卡',
		'Key': '钥匙',
		'FaceManger': '人脸',
		'FingerVein': '指静脉',
		'HandleUnlock': '把手',
		'ButtonUnlock': '按键'
	}
	if (isJSON(item.AlarmMsg)) {
		let msgType = JSON.parse(item.AlarmMsg)
		let MsgStr = msgType.UserType ? (msgJson[msgType.UserType] ? msgJson[msgType.UserType] : '') : ''
		let MsgTypeStr = jsonAlarmMsg[msgType.MsgType] ? jsonAlarmMsg[msgType.MsgType].title : ''
		let UserIdStr = msgType.UserId ? (String(msgType.UserId).replace(
			/\b(0+)/gi, "") ? String(msgType.UserId).replace(/\b(0+)/gi,
			"") : '0') : ''
		item.MsgType = msgType.MsgType
		item.MsgTypeStr = MsgTypeStr
		item.isCapture = jsonAlarmMsg[msgType.MsgType] ? jsonAlarmMsg[msgType.MsgType].isCapture : true
		item.Msg = msgType.Msg ? msgType.Msg : ''
		item.MsgStr = MsgStr
		item.UserIdStr = UserIdStr
		item.UserId = msgType.UserId ? msgType.UserId : ''
		item.UserType = msgType.UserType ? msgType.UserType : ''
		if (msgType.MsgType == 'AddUser' || msgType.MsgType == 'DelUser') {
			let totalDesc = MsgStr + UserIdStr + '-' + MsgTypeStr
			let nickName = ''
			for (let key in editInfo) {
				if (key == msgType.UserType) {
					let keyList = editInfo[key]
					keyList.forEach((keyItem) => {
						if (msgType.UserId == keyItem.UserId) {
							nickName = keyItem.NickName
						}
					})
				}
			}
			totalDesc = nickName ? (MsgStr + nickName + '-' + MsgTypeStr) : totalDesc
			item.totalDesc = totalDesc
		} else if (msgTypeIsEditArr().some(i => i === msgType.MsgType)) {
			let totalDesc = (jsonAlarmMsg[msgType.MsgType].type + jsonAlarmMsg[msgType.MsgType].desc) + ' ' + UserIdStr
			let nickName = ''
			for (let key in editInfo) {
				if (key == msgType.UserType) {
					let keyList = editInfo[key]
					keyList.forEach((keyItem) => {
						if (msgType.UserId == keyItem.UserId) {
							nickName = keyItem.NickName
						}
					})
				}
			}
			totalDesc = nickName ? (jsonAlarmMsg[msgType.MsgType].type + jsonAlarmMsg[msgType.MsgType].desc + ' ' +
				nickName) : totalDesc
			item.totalDesc = totalDesc
		} else {
			let totalDesc = jsonAlarmMsg[msgType.MsgType] ? jsonAlarmMsg[msgType.MsgType].title : msgType.MsgType
			item.totalDesc = totalDesc + ' ' + UserIdStr
		}
	} else {
		item.MsgType = ''
		item.Msg = ''
		item.UserIdStr = ''
		item.totalDesc = alarmJson[item.AlarmEvent] ? alarmJson[item.AlarmEvent] : ''
		if (!isDoorLock) {
			item.isCapture = true
			item.isDoorLock = isDoorLock
		}
	}
	return item
}
function isJSON(str) {
	if (typeof str == 'string') {
		try {
			var obj = JSON.parse(str);
			if (typeof obj == 'object' && obj) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	}
}
//判断是否可以编辑云事件消息昵称
export function msgTypeIsEditArr(){
	return ['AddUser','DelUser','FingerManger','FingerPrint','Passwd','Card','Face','FingerVein','FingerVeinUnlock','AddPasswd','FingerVeinUnLock','AddFingerPrint','AddCard','AddKey','AddPupil','AddFingerVein','AddTelecontrol','AddFace','AddPalmPrintUser','AddIrisUser','AddPalmVein','DelFingerPrint','DelPasswd','DelCard','DelTelecontrol','DelKey','DelPupil','DelPalmVein','DelFingerVein','DelFace','DelRemoteUser','DelPalmPrintUser','DelIrisUser']
}